package igin

import (
	"fmt"
	"go-library/igin/middleware"
)

const (
	DefaultQuitTimeout       int = 10
	DefaultReadHeaderTimeout int = 2
	DefaultReadTimeout       int = 5
	DefaultWriteTimeout      int = 10
	DefaultIdleTimeout       int = 30
)

func DefaultHttpMiddleware(h *Http) {
	//日志包装
	ht := "http"
	if h.conf.Tls {
		ht = "https"
	}
	h.Log = h.Log.With().
		Str("name", h.conf.Name).
		Str("server", fmt.Sprintf("%s[%s]", ht, h.conf.Addr)).
		Timestamp().Logger()

	//默认http中间间(日志和异常恢复)
	h.Engine.Use(middleware.DefaultRecover(h.Log), middleware.DefaultLogger(h.Log))
}
